package com.zzq.service.impl;

import com.zzq.domain.dto.SmileProductAppointmentDTO;
import com.zzq.domain.entity.SmilePhotographer;
import com.zzq.domain.dto.SmilePhotographerDTO;
import com.zzq.domain.entity.SmileProductAppointment;
import com.zzq.domain.search.PhotographerSearchParamet;
import com.zzq.result.SmileResult;
import com.zzq.service.ClientProductApponintmentService;
import com.zzq.service.SmilePhotographerService;
import com.zzq.service.SmileProductAppointmentService;
import com.zzq.util.BeanCopyUtils;
import com.zzq.enumerate.ApponintmentStatusEnum;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
public class ClientProductApponintmentServiceImpl implements ClientProductApponintmentService {

    @Autowired
    SmilePhotographerService photographerService;

    @Autowired
    SmileProductAppointmentService appointmentService;
    @Override
    public SmileResult getPhotographerList(PhotographerSearchParamet searchParamet) {
        List<SmilePhotographer> list = photographerService.list();
        List<SmilePhotographerDTO> smilePhotographerDTOS = BeanCopyUtils.copyBeanList(list, SmilePhotographerDTO.class);
        return SmileResult.sucess("获取成功",smilePhotographerDTOS);
    }

    @Override
    @Transactional
    public SmileResult addProductAppointment(SmileProductAppointmentDTO smileProductAppointmentDTO) {
        smileProductAppointmentDTO.setProductApponintmentStatus(ApponintmentStatusEnum.NOT_STARTED.getName());
        SmileProductAppointment smileProductAppointment = BeanCopyUtils.copyBean(smileProductAppointmentDTO, SmileProductAppointment.class);
        appointmentService.save(smileProductAppointment);
        return SmileResult.sucess("提交完成");
    }


}
